import { FairyEditor, FairyGUI } from "csharp";
import LocalCookie from "./com/utils/LocalCookie";
import UrlUtils from "./com/utils/UrlUtils";
import GameLayer from "./fgui/GameLayer";
import UISystem from "./fgui/UISystem";
import UIPluginView from "./fgui/view/UIPluginView";

require('../libs/laya.core.js');
/**
 * 全局类管理
 * @author clong 2020.11.20
 */
export default class Global {

    public static pulginView:UIPluginView;

    public static stage:FairyGUI.Stage = null;

    public static stageWidth:number = 1280;
    public static stageHeight:number = 720;

    /**
     * 全局初始化
     */
    public static init():void{

        console.log("---------------start---------------------" );

        // Laya.init( 1280 , 720 , Laya["WebGL"]);

        LocalCookie.Inst.init();

        FairyEditor.App.pluginManager.LoadUIPackage(UrlUtils.FAIRUI + 'BlackSkin');
        FairyEditor.App.pluginManager.LoadUIPackage(UrlUtils.FAIRUI + 'common');
        FairyEditor.App.pluginManager.LoadUIPackage(UrlUtils.FAIRUI + 'plugin');

        Global.stage = FairyGUI.GRoot.inst.displayObject.stage;

        FairyEditor.App.localStore.Load();

        GameLayer.start();
        
        // PanelRegister.registerClass("common","FileOpenComp",FileOpenComp);
        // PanelRegister.registerClass("common","TreeGroupView",TreeGroupView);
        // PanelRegister.registerClass("common","FileTreeItem",FileTreeItem);

        let menu = FairyEditor.App.menu.GetSubMenu( "help" );
        menu && menu.AddSeperator();//添加分割
        menu && menu.AddItem( "测试插件界面" , "test" , function(str):void{
            UISystem.Inst.CreateWindowView( UIPluginView );
        } );
    }
}